# coding= utf-8
import urllib

# 个人API申请服务信息摘录
App_ID = '16083814'
API_Key = 'RoWv7mmWchYBMvGtbYhc7aeF'
Secret_Key = '0wXxzQ26C254GEqTregIfNd6K4gHiMN5'

# 获取token值步骤(一般化步骤)
host = 'https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=' + API_Key + '&client_secret='+ Secret_Key
request = urllib.request.Request(host)
request.add_header('Content-Type','applocation/json;charset=UTF-8')
response = urllib.request.urlopen(request)
content = response.read()
access_token_init = content.decode("UTF-8")
print(access_token_init)# 获得的是字典形式的一串信息，需再处理
print(type(access_token_init))